{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "一、什么是形状和路径\n",
    "在一般的使用matplotlib进行绘图的时候，线形图、条形图、折线图、扇形图等等都是我们常见的一些绘图函数，但是有时候我们需要绘制一些特殊的形状和路径，比如我们要绘制一个椭圆，我们当然可以通过椭圆的函数表达式，然后选取一系列的（x,y)的坐标值进行依次相连，但是这样效率低下，而且不太好看。\n",
    "\n",
    "1、形状\n",
    "指的是matplotlib.patches包里面的一些列对象，比如我们常见的箭头，正方形，椭圆等等，也称之为“块”\n",
    "\n",
    "2、路径\n",
    "什么是路径？\n",
    "\n",
    "表示一系列可能断开的、可能已关闭的线和曲线段。\n",
    "\n",
    "指的是matplotlib.path里面所实现的功能，最简单的路径就是比如一条任意的曲线都可以看成是路径。比如我要绘制一个心形，就需要通过路径去完成。\n",
    "\n",
    "但是画图我们说最重要的是画图的步骤，下面以椭圆为例详细讲解绘制基本形状的一般步骤。\n",
    "https://matplotlib.org/stable/api/figure_api.html"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 形状的画图步骤基础"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[<matplotlib.patches.Patch object at 0x000002050CD31C10>, <matplotlib.patches.Patch object at 0x000002050E338580>, <matplotlib.patches.Patch object at 0x000002050E338640>, <matplotlib.patches.Patch object at 0x000002050E3386D0>, <matplotlib.patches.Patch object at 0x000002050E338790>]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PatchCollection at 0x2050e32a400>"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAvQAAALJCAYAAADbOLdlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm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ne84x0P6/7bb799zj777BxyyCG55ppr8pKXvCR33XXXMswUZkvQAwBz5+67785rX/va3HPPPTnuuOPy1re+dZMeZ4cddsgXvvCF7Lnnnvmnf/qnnHjiiROeKcyeoAcA5s4JJ5yQSy+9NL/2a7/2iCN81113zac+9akkyZ//+Z/nRz/60SSmCHND0AMAc+XSSy/NBz/4wVRVPvWpT2XHHXd8xI/53Oc+N7/zO7+Tu+66K3/0R380gVnC/BD0AMBc+eAHP5j7778/xx13XA455JCJPe6HPvShrFy5MmeffXa++tWvTuxxYdYEPQAwN66++uqcddZZWbFiRf7kT/5koo+922675d3vfneS5H3ve99EHxtmSdADAHPjIx/5SO677768+tWvzu677z7xx3/zm9+cnXbaKRdccEG+//3vT/zxYRYEPQAwF2644YacccYZSZK3v/3ty7KNlStX5vd+7/eSJKeeeuqybAOmTdADAHPh05/+dO64444cffTRefrTn75s2zn22GP/2fagO0EPAMyFz3/+80mS17/+9cu6nf333z8HH3xwbrnllpx55pnLui2YBkEPAMzctddemwsuuCCPetSj8hu/8RvLvr1jjjkmSfLFL35x2bcFy03QAwAz95WvfCVjjBx11FHZaaedln17z3/+85Mk5513Xu67775l3x4sJ0EPAMzcA9eFf8ELXjCV7e2xxx7Za6+9csstt+Tiiy+eyjZhuQh6AGCm7r///vzjP/5jkuToo4+e2naPOOKIJMk555wztW3CchD0AMBMrVmzJjfddFNWrVqVvfbaa2rbfSDov/GNb0xtm7AcBD0AMFOXXXZZkmS//fab6nYfCPpvfetbXkdPa4IeAJipB4J+Oa89vz6rVq3KE57whNxxxx1Zs2bNVLcNkyToAYCZuvTSS5NM/wx9kuy7775JkiuvvHLq24ZJEfQAwEzN6gx9IujZPAh6AGBm7r333lx11VWpql/F9TQ96UlPShIvuaE1QQ8AzMzNN9+c++67L4997GOz/fbbT337e+yxR5Lk6quvnvq2YVIEPQAwMzfddFOSZOedd57J9nffffckyU9+8pOZbB8mQdADADNz4403Jkl22WWXmWx/p512SpLcfvvtM9k+TIKgBwBmZtZn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cl770pcu6vb/5m79Jkrz85S9f1u3ANCzpOvRjjJvGGGctPnkDsIWyHrCc3vCGNyRJTj311GXdzs9//vN87WtfS1Ut+/84wDR4p1gAYC687nWvy6Me9aj8wz/8Q370ox8t23ZOPvnk/PKXv8wLX/jCPP7xj1+27cC0CHoAYC7ssssu+a3f+q2MMXL66acvyzZuv/32fOxjH0uS/Omf/umybAOmTdADAHPj2GOPTZKcfvrpueWWWyb++J/85Cdz44035tnPfvav3tAKuhP0AMDcOOSQQ/Kc5zwnv/jFL/Le9753oo/9y1/+MieddFKS5O1vf7t3h2WzIegBgLlRVTn55JOz1VZb5aMf/Wguv/zyiT32e9/73lx99dXZZ5998uIXv3hijwuzJugBgLlywAEH5E1velPuu+++vOUtb8kY4xE/5oUXXpgPfvCDqaqcfvrp2XrrrScwU5gPgh4AmDvve9/78rjHPS7nnXfer36JdVPdcccdee1rX5v7778/f/zHf5xDDz1043eCRgQ9ADB3dtlll5x88slJkre97W356le/ukmPc8899+SYY47JVVddlac97Wk54YQTJjlNmAuCHgCYS6961avyzne+M/fdd19e9rKX5bzzzntY97/rrrvyile8ImeeeWZWrlyZT3/609luu+2WZ7IwQ4IeAJhbJ5xwQv7gD/4gd955Z44++uj8xV/8Re69996N3u/mm2/Oi170ovzd3/1ddt5553zjG9/IAQccMIUZw/QJegBgbm211VY59dRT8+Y3vzl33313jj/++Bx88MG58MIL1/vLsnfeeWc+/vGP5ylPeUq+8Y1vZNWqVfnmN7+ZZz7zmTOYPUzHillPAADgoWy11VY55ZRT8pKXvCTHHntsvve97+VZz3pWVq1aldWrV+epT31qrrnmmqxZsyYXXXRRbrjhhiTJYYcdlk9+8pP59V//9RnvASwvQQ8AtPD85z8/3//+9/Oe97wnn/3sZ3PdddflzDPP/BfjDjzwwBx//PF5+ctf7s2j2CIIegCgjZUrV+bDH/5wPvShD+Wqq67Kueeemx/+8IfZfffds+eee2avvfbKvvvuK+TZogh6AKCdqsree++dvffee9ZTgZnzS7EAANCYoAcAgMYE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H1JCtnPe9lPB7nLf73iCRvWedreyweh/+Y5J+y8ItjM5/zFL8PrAmb8Zqwpa8HD+N7wJqwhawJk1wPlvWdYhd/i/eoJP91LPzoaJPGdLa5799SbOnHYEvf/8QxeDiqarcsnJX52tj4ayxbsSZs/vu3MVv6/ieOQeIYLNXDWQ+WNegBAIDltbn9whEAAGxRBD0AADQm6AEAoDFBDwAAjQl6AABo7P8HMmht5eLrBW8AAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 720x720 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 导入包\n",
    "from matplotlib import path\n",
    "from matplotlib import patches  # 存储相应的模型\n",
    "from matplotlib import pyplot   # 创建基本画布大小\n",
    "#可存放文件集合 patches[]   append()方法添加只能是patches对象\n",
    "from matplotlib.collections import PatchCollection  \n",
    "\n",
    "\n",
    "# 第一步：创建画图对象以及子图\n",
    "fig = pyplot.figure(figsize=(10,10)) # 创建画布\n",
    "ax = fig.add_subplot(121, aspect='auto')  # 第一个参数为行列块  子图只能拿ax的句柄,主图plt.subplot() 可以有fig 和 ax 这个就可以有俩个参数\n",
    "ax1= fig.add_subplot(122, aspect='auto')  # 可以添加多个子图\n",
    "\n",
    "ax.set_title('qwq')    # 子图标题\n",
    "ax1.set_title('awa')   # 子图标题\n",
    "\n",
    "# 用来正常显示中文\n",
    "pyplot.rcParams['font.sans-serif'] = ['SimHei']\n",
    "# 用来正常显示负号\n",
    "pyplot.rcParams['axes.unicode_minus'] = False\n",
    "\n",
    "fig.subplots_adjust(left=0.005, right=0.995, top=0.87, bottom=0.01)  # 设置边距与子图的距离\n",
    "fig.suptitle(\"湖北省\", x=0.5, y=0.96, fontsize=14)    # 设置主标题 整个图的标题\n",
    "# 第二步：创建相对应的形状——创建椭圆\n",
    "e1 = patches.Circle((0.45,0.22),radius=0.05,angle=-30 , linewidth=2, fill=False, zorder=2)\n",
    "\n",
    "# colors = ['#ffffff','#0000FF','#FFFF00','#FFA500','#FF0000']\n",
    "# lable=['无风险','一般','较重','严重','特别严重']\n",
    "# labels = lable.copy()\n",
    "# patchess = [mpatches.Patch(color=colors[i], label=\"{:s}\".format(labels[i])) for i in range(len(colors))]\n",
    "\n",
    "# 第三步：将图形添加到图中——这是非常核心的一步 # 可以使用add_patch添加多个\n",
    "# ax.add_patch(e2)\n",
    "ax1.add_patch(e1) \n",
    "\n",
    "# 也可以采用下面那种方式\n",
    "patches=[]           #创建容纳对象的集合\n",
    "# patches.append(e1)   #将创建的形状全部放进去\n",
    "# patches.append(e2)\n",
    "\n",
    "collection=PatchCollection(patches)  #构造一个Patch的集合\n",
    "\n",
    "ax.add_collection(collection)    #将集合添加进axes对象里面去\n",
    "\n",
    "# plt.gca()  # 获取子图\n",
    "# plt.gcf()  # 获取主图\n",
    "# box = ax.get_position() # 获取图中位置\n",
    "# ax.set_position([box.x0, box.y0, box.width, box.height])  # 固定坐标轴位置\n",
    "# ax.legend(handles=patches, bbox_to_anchor=(1, 1), ncol=1) # 图片微调\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 实战案列\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAagAAAEZCAYAAADCJLEQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAqu0lEQVR4nO3de5gc1X3m8e9PN0ACIUBCIIQ0SDNgQGAZ29wNcmwTRtiYZL1xHtubxbH9bC6eSTabxCS+4U2yYTeXJ5lZe31JsiTZ2MEb9oEYzTh2jLEN2AFz1QXBjKTRDV2Q0Oh+19k/zmnRDD0zPT3ddU5Vv5/n6UfqrumqX1V311t16lSVOecQERFJzYTYBYiIiFSigBIRkSQpoEREJ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dSzFH1u4B/iQc26gljpSFpbtzwK34Jf5XOD9oTm0GvfhOz+UB9RL+D3QR/AbCIfM7AEzm+Kc24g/DvLrwNP4g/IfrcOsxPZt4J/xHUy+AvwVMMfMZpf9zR/g91bXh+HjOdxQ0/Scc3uAW8PjRfznfrtzLtXm1Kaji8WK1EHYA7oOf+D+mrLXP4bvTflxfNPrQvye1rucc3lvJhVpKHWSEKmPB/E9vH5xyOsPh9eeB6biu0N/GX97CBEZgfagREQkSToGJSIiSVJAiYhIkhRQIiKSJAWUiIgkSQElIiJJ+v81mbj3/VaROwAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import matplotlib.path as mpath\n",
    "import matplotlib.lines as mlines\n",
    "import matplotlib.patches as mpatches\n",
    "from matplotlib.collections import PatchCollection\n",
    "\n",
    "\n",
    "\n",
    "def label(xy, text):\n",
    "    y = xy[1] - 0.15  # 标签放置在patch下方的0.15位置处\n",
    "    plt.text(xy[0], y, text, ha=\"center\", family='sans-serif', size=14) # 长宽，文本，位置，字体，字体大小\n",
    "\n",
    "fig, ax = plt.subplots()   #fig:尺寸  ax:句柄 ax.set_title  设置标题  前俩个参数行，自动分配格子\n",
    "\n",
    "# 创建一个3x3的网格\n",
    "grid = np.mgrid[0.2:0.8:3j, 0.2:0.8:3j].reshape(2, -1).T\n",
    "\n",
    "\n",
    "#创建容纳patch的集合\n",
    "patches = []\n",
    " \n",
    "# 添加一个圆Circle\n",
    "circle = mpatches.Circle(grid[0], 0.1, ec=\"none\")\n",
    "patches.append(circle) \n",
    "label(grid[0], \"Circle\")\n",
    "\n",
    "# 添加一个Rectangle\n",
    "rect = mpatches.Rectangle(grid[1] - [0.025, 0.05], 0.05, 0.1, ec=\"none\")\n",
    "patches.append(rect)\n",
    "label(grid[1], \"Rectangle\")\n",
    " \n",
    "# 添加一个楔形，即圆的一部分\n",
    "wedge = mpatches.Wedge(grid[2], 0.1, 30, 270, ec=\"none\")\n",
    "patches.append(wedge)\n",
    "label(grid[2], \"Wedge\")\n",
    " \n",
    "# 添加一多边形，这里添加一个五边形\n",
    "polygon = mpatches.RegularPolygon(grid[3], 5, 0.1)\n",
    "patches.append(polygon)\n",
    "label(grid[3], \"Polygon\")\n",
    " \n",
    "# 添加一个椭圆，也可以使用Arc\n",
    "ellipse = mpatches.Ellipse(grid[4], 0.2, 0.1)\n",
    "patches.append(ellipse)\n",
    "label(grid[4], \"Ellipse\")\n",
    " \n",
    "# 添加一个箭头\n",
    "arrow = mpatches.Arrow(grid[5, 0] - 0.05, grid[5, 1] - 0.05, 0.1, 0.1,\n",
    "                       width=0.1)\n",
    "patches.append(arrow)\n",
    "label(grid[5], \"Arrow\")\n",
    "\n",
    "\n",
    "\n",
    "# 添加一个路径path，路径的详细解释后面会讲到，相比于简单的patch，稍显复杂\n",
    "Path = mpath.Path\n",
    "path_data = [\n",
    "    (Path.MOVETO, [0.018, -0.11]),\n",
    "    (Path.CURVE4, [-0.031, -0.051]),\n",
    "    (Path.CURVE4, [-0.115, 0.073]),\n",
    "    (Path.CURVE4, [-0.03, 0.073]),\n",
    "    (Path.LINETO, [-0.011, 0.039]),\n",
    "    (Path.CURVE4, [0.043, 0.121]),\n",
    "    (Path.CURVE4, [0.075, -0.005]),\n",
    "    (Path.CURVE4, [0.035, -0.027]),\n",
    "    (Path.CLOSEPOLY, [0.018, -0.11])]\n",
    "codes, verts = zip(*path_data)\n",
    "path = mpath.Path(verts + grid[6], codes)\n",
    "patch = mpatches.PathPatch(path)\n",
    "patches.append(patch)\n",
    "label(grid[6], \"PathPatch\")\n",
    "\n",
    "\n",
    "# 添加一个box\n",
    "fancybox = mpatches.FancyBboxPatch(\n",
    "    grid[7] - [0.025, 0.05], 0.05, 0.1,\n",
    "    boxstyle=mpatches.BoxStyle(\"Round\", pad=0.02))\n",
    "patches.append(fancybox)\n",
    "label(grid[7], \"FancyBboxPatch\")\n",
    " \n",
    "# # 添加一条折线——注意这里的折线和前面所画的这显示不一样的，这里的折线是一个形状\n",
    "x, y = np.array([[-0.06, 0.0, 0.1], [0.05, -0.05, 0.05]])\n",
    "line = mlines.Line2D(x + grid[8, 0], y + grid[8, 1], lw=5., alpha=0.3)\n",
    "label(grid[8], \"Line2D\")\n",
    "\n",
    "\n",
    "#np.linspace(start, stop, num=10, endpoint=True, retstep=False, dtype=None)，\n",
    "# 通俗意思就是按起点，终点，分为10份，endpoint:保留小数,retstep:分为俩部分（array，num）元组，array是结果数组，num是间隔大小\n",
    "colors = np.linspace(0, 1, len(patches))   \n",
    "#将patch集合包装成PatchCollection\n",
    "collection = PatchCollection(patches, cmap=plt.cm.cool, alpha=0.3)  # alpha 透明度   cmap=plt.cm.cool 颜色\n",
    "collection.set_array(np.array(colors))\n",
    "#将PatchCollection添加给axes对象\n",
    "ax.add_collection(collection) \n",
    "#将折线添加到axes对象\n",
    "ax.add_line(line)\n",
    " \n",
    "plt.axis('equal')   #改坐标精度\n",
    "plt.axis('off')    # 去坐标轴\n",
    "plt.tight_layout()   #自动调整子图参数，防止突出\n",
    " \n",
    "plt.show()\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAD8CAYAAAB3u9PLAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAQw0lEQVR4nO3df4xlZX3H8fenLGCCRNBFWJZFIN0UsbUVJwhqGlrRwMaw+IMEYir4I1NbSTVp0mBJsPGfapvYxEClEyRCQwCLImtdiyAYahqQgSw/dldkITbsusoIDUq02NVv/5hn7c1wZ2d2z5l7L/T9Sm7mOec8c54vzwz7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i4zefDwIdGWN8L5gf4FPNvWgBeBvxL+939LnDSqOdwmXX+bftdfBC4Czh5DDXeAOwG/qf9bn4I+AjwkbY9zP8xrcfbz3nRu/jGXOclA3N5D/DmMdT4VuavUz408O/lhq7z6aMrJEnAhJ0ykiSNj4EgSQIMBElSYyBIkgADQZLUGAiSJMBAkCQ1/wslA/PGXbZfPAAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "from matplotlib.path import Path\n",
    "import matplotlib.patches as patches\n",
    " \n",
    "#import matplotlib.patheffects\n",
    "#import matplotlib.transforms\n",
    " \n",
    "verts = [\n",
    "    (0., 0.), # 矩形左下角的坐标(left,bottom)\n",
    "    (0., 1.), # 矩形左上角的坐标(left,top)\n",
    "    (1., 1.), # 矩形右上角的坐标(right,top)\n",
    "    (1., 0.), # 矩形右下角的坐标(right, bottom)\n",
    "    (0., 0.), # 封闭到起点   \n",
    "     ]\n",
    " \n",
    "codes = [Path.MOVETO,\n",
    "         Path.LINETO,\n",
    "         Path.LINETO,\n",
    "         Path.LINETO,\n",
    "         Path.CLOSEPOLY,\n",
    "         ]\n",
    "# STOP1 个顶点（忽略）\n",
    "# 整个路径结束的标记（当前不需要并且被忽略）\n",
    "\n",
    "# MOVETO1 个顶点\n",
    "# 拿起笔并移动到给定的顶点。\n",
    "\n",
    "# LINETO1 个顶点\n",
    "# 从当前位置到给定顶点画一条线。\n",
    "\n",
    "# CURVE31个控制点，1个端点\n",
    "# 用给定的控制点从当前位置到给定的终点绘制一条二次贝塞尔曲线。\n",
    "\n",
    "# CURVE42个控制点，1个端点\n",
    "# 用给定的控制点从当前位置到给定的端点绘制一条三次贝塞尔曲线。\n",
    "\n",
    "# CLOSEPOLY1 个顶点（忽略）\n",
    "# 在当前折线的起点绘制一条线段。\n",
    " \n",
    "path = Path(verts, codes) #创建一个路径path对象(坐标，操作步骤)\n",
    " \n",
    "#依然是三步走\n",
    "#第一步：创建画图对象以及创建子图对象\n",
    "fig = plt.figure()\n",
    "ax = fig.add_subplot(111)\n",
    " \n",
    "#第二步：创建一个patch，路径依然也是通过patch实现的，只不过叫做pathpatch\n",
    "patch = patches.PathPatch(path, facecolor='orange', lw=2)  # lw = 2 边线宽度2\n",
    " \n",
    "#第三步：将创建的patch添加到axes对象中\n",
    "ax.add_patch(patch)\n",
    " \n",
    "#显示\n",
    "ax.set_xlim(-2,2)  #设置明确的范围的x轴，y轴\n",
    "ax.set_ylim(-2,2)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    " \n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.patches as patches\n",
    "import matplotlib.path as path\n",
    " \n",
    "fig = plt.figure()\n",
    "ax = fig.add_subplot(111)\n",
    " \n",
    "# 固定随机数种子\n",
    "np.random.seed(19680801)\n",
    "\n",
    "# 产生1000组随机数，并进行组织\n",
    "data = np.random.randn(1000)\n",
    "n, bins = np.histogram(data, 100)  # bins =100 表示有100个区间对应100个数据\n",
    "print(data.shape,n.shape,bins.shape,sep='   ')\n",
    " \n",
    "# # 得到每一个条形图的四个角落的位置\n",
    "left = np.array(bins[:-1])\n",
    "right = np.array(bins[1:])\n",
    "bottom = np.zeros(len(left))\n",
    "top = bottom + n\n",
    "nrects = len(left)\n",
    " \n",
    "nverts = nrects*(1+3+1)\n",
    "verts = np.zeros((nverts, 2))\n",
    "codes = np.ones(nverts, int) * path.Path.LINETO\n",
    "codes[0::5] = path.Path.MOVETO\n",
    "codes[4::5] = path.Path.CLOSEPOLY\n",
    "verts[0::5,0] = left\n",
    "verts[0::5,1] = bottom\n",
    "verts[1::5,0] = left\n",
    "verts[1::5,1] = top\n",
    "verts[2::5,0] = right\n",
    "verts[2::5,1] = top\n",
    "verts[3::5,0] = right\n",
    "verts[3::5,1] = bottom\n",
    " \n",
    "# #第二步：构造patches对象\n",
    "barpath = path.Path(verts, codes)\n",
    "patch = patches.PathPatch(barpath, facecolor='green', edgecolor='yellow', alpha=0.5)\n",
    " \n",
    "#添加patch到axes对象\n",
    "ax.add_patch(patch)\n",
    " \n",
    "ax.set_xlim(left[0], right[-1])\n",
    "ax.set_ylim(bottom.min(), top.max())\n",
    " \n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from mpl_toolkits.basemap import Basemap\n",
    "map = Basemap(llcrnrlon=108.25, llcrnrlat=28.75, urcrnrlon=116.25,\n",
    "                urcrnrlat=33.5,\n",
    "                projection='cyl')\n",
    "map.readshapefile('文件', 'hb_fenqu_hb', default_encoding='unicode_escape', color='#aaa',\n",
    "                    drawbounds=True)"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "3cb250e525bdc45e0c81f60515e2b301d41451e11e00718716680ec78afef40b"
  },
  "kernelspec": {
   "display_name": "Python 3.8.8rc1 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
